#include <cstdio>
#include <algorithm>
#include <cstring>

using namespace std;

struct Student
{
    int score;
    char num[ 21 ];
};

bool operator < ( const Student a, const Student b )
{
    if ( a.score > b.score )
        return true;
    if ( a.score < b.score )
        return false;
    return strcmp( a.num, b.num ) < 0;
}

int main( )
{
    int n, m, s[ 11 ], p, i, j, t1, t2, count;
    Student stu[ 1000 ];
    while ( scanf("%d", &n) != EOF && n )
    {
        scanf("%d%d", &m, &p);
        count = 0;
        for ( i = 1; i <= m; i++ )
            scanf("%d", &s[ i ]);
        for ( i = 0; i < n; i++ )
        {
            scanf("%s%d", stu[ i ].num, &t1);
            stu[ i ].score = 0;
            for ( j = 0; j < t1; j++ )
            {
                scanf("%d", &t2);
                stu[ i ].score += s[ t2 ];
            }
            if ( stu[ i ].score >= p )
                count++;
        }
        sort( stu, stu + n );
        printf("%d\n", count);
        for ( i = 0; i < count; i++ )
            printf("%s %d\n", stu[ i ].num, stu[ i ].score);
    }
    return 0;
}
